<?php 
require_once 'sesi_login.php';
require_once 'konfigurasi.php';
fungsi('umum');

define('PAGE', 'Laporan');
define('PAGE_ICO', 'icon-stats');
define('PAGE_URL', 'laporan.php');
	
koneksi_buka();
panggil_header();

$tahun = "";

if(isset($_POST['tahun'])) {
	$tahun = $_POST['tahun'];
	if($tahun == 0){
		$tahun = "";
	}
}

$nama_bulan=array("Januari","Pebruari","Maret","April","Mei","Juni","Juli","Agustus","September",
"Oktober","November","Desember");

$text_q_perkara= "select *, MONTH(tgl_dimulai) as bulan, count(kd_perkara) as jumlah from t_perkara where YEAR(tgl_dimulai) like '%$tahun%' group by MONTH(tgl_dimulai)";
$q_perkara = mysql_query($text_q_perkara);
?>

<div id="da-content-area">
<div class="row-fluid">

	<div class="span12">
		<div class="da-panel collapsible">
			<div class="da-panel-header">
				<span class="da-panel-title">
					<i class="icon-notes-2"></i> Laporan
				</span>
			</div>
			
			<div class="da-panel-toolbar">
				<div class="btn-toolbar">
					<div class="btn-group">
						<button class="btn disabled">Jumlah</button>
						<a href="laporan.jenis.perkara.php" class="btn">Jenis</a>
						<a href="laporan.polsek.perkara.php" class="btn">Polsek</a>						
						<a href="laporan.beban.jaksa.php" class="btn">Beban Jaksa</a>
					</div>
				</div>
			</div>
			<div class="da-panel-content da-form-container">

				<form class="da-form da-form-inline" method="post" action="laporan.php">
					<div class="da-form-row da-column-row">
						<div class="da-form-item da-form-cols">
							<div class="col-2-8">
								<label class="da-form-label">Tahun</label>
								<select id="dc-target" name="tahun">
									
									<option value="0">Semua</option>
									<?php	
										$q_thn_perkara = mysql_query("select YEAR(tgl_dimulai) as y_perkara from t_perkara group by YEAR(tgl_dimulai)");
										while($dt_thn_perkara = mysql_fetch_array($q_thn_perkara)){
									?>
											<option value="<?php echo $dt_thn_perkara['y_perkara']?>"><?php echo $dt_thn_perkara['y_perkara']?></option>
									<?php } ?>
								</select>
							</div>
							<div class="col-2-8">
								<input type="submit" value="Tampilkan" class="btn btn-danger" />
								<input type="hidden" id="tahun" value="<?php echo $tahun==''?'-':$tahun;?>" />
	
							</div>
						</div>
					</div>
				</form>

			</div>
			
			<div class="da-panel-content da-table-container">
				<table id="da-ex-datatable-numberpaging" class="da-table">
					<thead>
						<tr>
							<th>No</th>
							<th>BulanAngka</th>
							<th>Bulan</th>
							<th>Jumlah</th>
						</tr>
					</thead>
					<tbody>
						
						<?php 
							$i = 1;
							while($dt_perkara = mysql_fetch_array($q_perkara)){?>
							<tr>
								<td><?php echo $i; $i++;?></td>
								<td><?php echo $dt_perkara['bulan'];?></td>
								<td><?php echo konversi_bulan($dt_perkara['bulan']);?></td>
								<td><?php echo $dt_perkara['jumlah'];?></td>
							</tr>							
						<?php }?>

					</tbody>
				</table>
			</div>
	
			<div class="da-panel-content">
				<h3>Statistik Jumlah Perkara <?php echo $tahun==""?"":"Tahun ".$tahun;?></h3>
				<div id="da-ex-flot" style="height:330px;"></div>
			</div>
		</div>
	</div>

</div>
</div
<?php
panggil_footer();
koneksi_tutup();
?>
